<template>
	<view v-if="pageShow" class="container">
		<view v-if="dataList.length > 0">
			<view class="content" v-for="(item, index) in dataList" :key="index">
				<view class="date">
					{{item.time}}
				</view>
				<view class="detail-item" @click="goDetail(item)">
					<view class="title">
						{{item.title}}
					</view>
					<view class="item-content">
						<mp-html
							:content="item.subtitle" 
							container-style="font-size: 28rpx;color: #999;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 3;overflow: hidden;">
						</mp-html>
					</view>
					<view class="item-logo">
						<image src="https://xzcs-public-files.oss-cn-beijing.aliyuncs.com/static/New-my/notice-log.png" mode=""></image>
						<text>小竹官方</text>
					</view>
				</view>
				<view class="view-detail solid-top" @click="goDetail(item)">
					查看详情
				</view>
			</view>
		</view>
		<view v-if="dataList.length === 0" class="empty-wrap" >
		  <image class="empty-img" src="https://xzcs-public-files.oss-cn-beijing.aliyuncs.com/static/coupon/contentVanshi.png"></image>
		  <text class="tips">暂无通知</text>
		</view>
	</view>
</template>

<script>
	import newsApi from "@/api/myNews.js"
	export default {
		data() {
			return {
				dataList: [],
				pageShow: false
			}
		},
		onLoad() {
			this.getList()
		},
		methods: {
			async getList() {
				let res = await newsApi.getList({type: 1})
				if(res.code === 1) {
					let arr  = res.data
					arr.forEach(val => {
						val.time = this.$moment(val.createtime*1000).format('MM-DD')
						val.content = val.content.replace(/<[^>]*>/g, "")
					})
					this.dataList = arr
					this.pageShow = true
					console.log(this.dataList)
				}
			},
			
			goDetail(val) {
				uni.navigateTo({
					url: '/pagesMy3/detailNews/detailNews?id=' + val.id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import "../newsDetail/newsDetail.scss";
</style>
